{template cashier_header}
<script>
    $(function(){
        $(".key").keyup(function(){
            var key = $(this).val();
            var url = "{php echo $this->createMobileUrl('cashier',array('op' => 'get_member'))}";
            if(key != ''){
                $.ajax({
                    type : "post",
                    url : url,
                    data : {'key' : key},
                    success : function(data){
                        $("#member-list").html(data);
                    }
                });
            }
        });
        $(".back").click(function(){
            location.href=window.history.go(-1);
        });
        $(".add").click(function(){
            var member_id = $("#member-list").val();
            var remark = $("#remark").val();
            if(member_id > 0 ){
                var url = "{php echo $this->createMobileUrl('cashier',array('op' => 'order_add'))}";
                $.ajax({
                    type : "post",
                    url : url,
                    data : {'member_id' : member_id, 'remark' : remark},
                    success : function(data){
                        var json = JSON.parse(data);
                        if(json.errorCode == 0){
                            location.href="{php echo $this->createMobileUrl('cashier',array('op' => 'order_goods_add'))}&order_id="+json.order_id;
                        }else{
                            alert("服务器繁忙，请重试！");
                        }
                    }
                });
            }else{
                alert("请选择客户");
            }
        });
    });
</script>
<div class="content">
    <div style="padding: 0px 10px 0px 10px;">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <div class="panel-title">新建订单</div>
                </div>
                <div class="panel-body">
                    <input type="text" class="form-control key" placeholder="请输入客户电话/名称/助记码搜索" />
                    <div>
                        <select class="form-control" id="member-list">
                        </select>
                    </div>
                    <div>
                        备注：
                        <textarea class="form-control" id="remark"></textarea>
                    </div>
                    <div align="right">
                        <button class="btn btn-success add">确认</button>
                        <button class="btn btn-danger back" type="button">返回</button>
                    </div>
                </div>
            </div>
    </div>
</div>
{template 'footer'}